//
//  WNThreadManager.swift
//  WalkNovel
//
//  Created by Kevin on 2023/7/4.
//

import UIKit

class WNThread: NSObject {
    // 新线程中运行
    class func wn_runInNewThread(_ action: @escaping () -> Void){
        DispatchQueue.global().async {
            action()
        }
    }
    
    // 主线程中运行
    class func wn_runInMainThread(_ action: @escaping () -> Void){
        DispatchQueue.main.async(execute: {
            action()
        })
    }
    
    // 延时执行方法
    class func wn_delay(_ delay:Double, closure:@escaping ()->()) {
        DispatchQueue.main.asyncAfter(
            deadline: DispatchTime.now() + Double(Int64(delay * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC), execute: closure)
    }
}
